home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / FLTK-1.0.6 / src / Fl_Return_Button.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-19  |  2.1 KB  |  70 lines

  1. //
  2. // "$Id: Fl_Return_Button.cxx,v 1.5 1999/01/19 19:26:46 mike Exp $"
  3. //
  4. // Return button widget for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-1999 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems to "fltk-bugs@easysw.com".
  24. //
  25.  
  26. #include <FL/Fl.H>
  27. #include <FL/Fl_Return_Button.H>
  28. #include <FL/fl_draw.H>
  29.  
  30. int fl_return_arrow(int x, int y, int w, int h) {
  31.   int size = w; if (h<size) size = h;
  32.   int d = (size+2)/4; if (d<3) d = 3;
  33.   int t = (size+9)/12; if (t<1) t = 1;
  34.   int x0 = x+(w-2*d-2*t-1)/2;
  35.   int x1 = x0+d;
  36.   int y0 = y+h/2;
  37.   fl_color(FL_LIGHT3);
  38.   fl_line(x0, y0, x1, y0+d);
  39.   fl_yxline(x1, y0+d, y0+t, x1+d+2*t, y0-d);
  40.   fl_yxline(x1, y0-t, y0-d);
  41.   fl_color(fl_gray_ramp(0));
  42.   fl_line(x0, y0, x1, y0-d);
  43.   fl_color(FL_DARK3);
  44.   fl_xyline(x1+1, y0-t, x1+d, y0-d, x1+d+2*t);
  45.   return 1;
  46. }
  47.  
  48. void Fl_Return_Button::draw() {
  49.   if (type() == FL_HIDDEN_BUTTON) return;
  50.   draw_box(value() ? (down_box()?down_box():down(box())) : box(),
  51.        value() ? selection_color() : color());
  52.   int W = h();
  53.   if (w()/3 < W) W = w()/3;
  54.   fl_return_arrow(x()+w()-W-4, y(), W, h());
  55.   draw_label(x(), y(), w()-W+4, h());
  56. }
  57.  
  58. int Fl_Return_Button::handle(int event) {
  59.   if (event == FL_SHORTCUT &&
  60.       (Fl::event_key() == FL_Enter || Fl::event_key() == FL_KP_Enter)) {
  61.     do_callback();
  62.     return 1;
  63.   } else
  64.     return Fl_Button::handle(event);
  65. }
  66.  
  67. //
  68. // End of "$Id: Fl_Return_Button.cxx,v 1.5 1999/01/19 19:26:46 mike Exp $".
  69. //
  70.